package com.example.smartmirror2;

import ohos.aafwk.ability.IAbilityContinuation;
import ohos.aafwk.content.IntentParams;
import ohos.ace.ability.AceAbility;
import ohos.aafwk.content.Intent;
import ohos.bundle.IBundleManager;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;
import ohos.security.SystemPermission;

import java.util.ArrayList;
import java.util.List;

public class MainAbility extends AceAbility  implements IAbilityContinuation{
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        requestPermission();
    }

    //获取权限
    private void requestPermission() {
        String[] permission = {

                "ohos.permission.DISTRIBUTED_DATASYNC",
                "ohos.permission.ACCELEROMETER",
                "ohos.permission.MICROPHONE"
        };
        List<String> applyPermissions = new ArrayList<>();
        for (String element : permission) {
            if (verifySelfPermission(element) != 0) {
                if (canRequestPermission(element)) {
                    applyPermissions.add(element);
                }
            }
        }
        requestPermissionsFromUser(applyPermissions.toArray(new String[0]), 0);
        requestPermissionsFromUser(applyPermissions.toArray(new String[1]), 0);
        requestPermissionsFromUser(applyPermissions.toArray(new String[2]), 0);
    }
    @Override
    public void onStop() {
        super.onStop();
    }

}
